<template>
    <div id="seachDialog">
      <a-modal
        title="撤户"
        v-model="chehuData.show"
        width="800px"
        style="overflow:hidden"
        @cancel="handleClose">
        <el-row style="padding:20px 30px">
            <el-form ref="Form" size="small" :model="parames" :rules="rules" label-width="100px">
                <el-row :gutter="30">
                    <el-col :span="12">
                        <el-form-item label="审批人:" prop="reviewerId">
                            <userTree v-model="parames.reviewerId" :currentValue="parames.reviewerId"></userTree>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="企业名称:">
                            <el-input v-model="parames.customerName"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="30">
                    <el-col :span="12">
                        <el-form-item label="信用代码:">
                            <el-input v-model="parames.creditCode"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="五证合一:">
                            <el-radio v-model="parames.fiveInOne" :label="true">是</el-radio>
                            <el-radio v-model="parames.fiveInOne" :label="false">否</el-radio>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="企业联系人:">
                            <el-input v-model="parames.contacts"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="企业联系人方式:" label-width="120px">
                            <el-input v-model="parames.contactMobile"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="代理会计:">
                            <el-input v-model="parames.accountant"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="代理会计联系方式:" label-width="130px">
                            <el-input v-model="parames.accountantMobile"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="合同起始日期:">
                            <el-date-picker
                                style="width:100%"
                                v-model="parames.billingStartDate"
                                type="date"
                                placeholder="选择日期">
                                </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="合同截止日期:">
                            <el-date-picker
                                style="width:100%"
                                v-model="parames.billingEndDate"
                                type="date"
                                placeholder="选择日期">
                                </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="缴费起始日期:">
                            <el-date-picker
                                style="width:100%"
                                v-model="parames.paymentStartDate"
                                type="date"
                                placeholder="选择日期">
                                </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="缴费截止日期:">
                            <el-date-picker
                                style="width:100%"
                                v-model="parames.paymentEndDate"
                                type="date"
                                placeholder="选择日期">
                                </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="是否欠代理费:">
                            <el-radio v-model="parames.arrears" :label="true">是</el-radio>
                            <el-radio v-model="parames.arrears" :label="false">否</el-radio>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="欠费原因:">
                            <el-input v-model="parames.arrearsReason"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="是否退代理费:">
                            <el-radio v-model="parames.refund" :label="true">是</el-radio>
                            <el-radio v-model="parames.refund" :label="false">否</el-radio>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="退款金额:" prop="refundAmount">
                            <el-input v-model="parames.refundAmount"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="退费人名称:">
                            <el-input v-model="parames.refundPerson"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="退费人联系方式:" label-width="130px">
                            <el-input v-model="parames.refundMobile"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="退费方式:">
                            <el-select style="width:100%" v-model="parames.refundWay" placeholder="请选择">
                                <el-option v-for="(item,index) in fukuanData" :key="index" :label="item.desc" :value="item.name"></el-option>
                            </el-select>
                        </el-form-item>
                       
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="退费银行名称:">
                            <el-input v-model="parames.refundBank"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="退费账号:">
                            <el-input v-model="parames.refundAccount"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="企业性质:">
                            <el-select style="width:100%" size="small" filterable v-model="parames.businessNature" placeholder="请选择">
                                <el-option label="一般人" value="NORMAL_PERSON"></el-option>
                                <el-option label="小规模纳税人" value="SMALL_SCALE_TAXPAYER"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="会计流转信息:">
                            <el-input v-model="parames.accountingTurnover"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="企业账务情况说明:" label-width="130px">
                            <el-input v-model="parames.accountInformation"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="是否告知企业情况:" label-width="130px">
                            <el-radio v-model="parames.inform" :label="true">是</el-radio>
                            <el-radio v-model="parames.inform" :label="false">否</el-radio>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </el-row>
        <span slot="footer" class="dialog-footer">
            <el-button size="small" @click="handleClose">取消</el-button>
            <el-button size="small" type="primary" @click="handleSave">保存</el-button>
        </span>
      </a-modal>
    </div>
</template>

<script>
export default {
    props: ['chehuData'],
    data() {
        return {
          parames: {
            contractId: '', //合同ID
            reviewerId: '', //审批人ID
            customerName: '', //客户名称
            creditCode: '', //信用代码
            fiveInOne: '', //五证合一
            contacts: '', //企业联系人
            contactMobile: '', //企业联系人方式
            accountant: '', //代理会计
            accountantMobile: '', //代理会计联系方式
            billingStartDate: '', //代账起始日期
            billingEndDate: '', //代账截止日期
            paymentStartDate: '', //缴费起始日期
            paymentEndDate: '', //缴费截止日期
            refundAmount: '', //退款金额
            arrears: '', //是否欠代理费
            arrearsReason: '', //欠费原因
            refund: '', //是否退代理费
            refundPerson: '', //退费人名称
            refundMobile: '', //退费人联系方式
            refundWay: '', //退费方式
            refundBank: '', //退费银行名称
            refundAccount: '', //退费账号
            businessNature: '', //企业性质（NORMAL_PERSON("一般人"), SMALL_SCALE_TAXPAYER("小规模纳税人")）
            accountingTurnover: '', //会计流转信息
            accountInformation: '', //企业账务情况说明
            inform: '', //告知是否企业情况
          },
          fukuanData: [], //退费方式
          rules: {
            reviewerId: [{ required: true, message: '必填', trigger: ['change','blur' ]}],
            refundAmount: [{ required: true, message: '必填', trigger: ['change','blur' ]}],
          }
        };
    },
    methods: {
        handleClose () {
            this.chehuData.show = false
        },
        checkValue (value) { //来源获取信息
            this.parames.sourceTypeEnum = value
        },
        handleSave () {
            this.$refs['Form'].validate((valid) => {
                if (valid) {
                    this.$post(this.$api.postContactRevokeApply,this.parames).then(response => {
                        if (response.data.succeed) {
                            this.$emit('checkOpen','2')
                            this.$message({
                                message: '撤户成功',
                                type: 'success'
                            });
                            this.handleClose()
                        }
                    })
                }       
            })
        },
        render () {
            this.$post(this.$api.postContactRevokeInformation,{ //根据id获取详情
                contractId: this.parames.contractId
            }).then(response => {
                if (response.data.succeed) {
                    let data = response.data.data
                    this.parames.customerName = data.customerName
                    this.parames.creditCode = data.creditCode
                    this.parames.fiveInOne = data.fiveInOne //五证合一
                    this.parames.contacts = data.contacts //企业联系人
                    this.parames.contactMobile = data.contactMobile //企业联系人方式
                    this.parames.accountant = data.accountant //代理会计
                    this.parames.accountantMobile = data.accountantMobile //代理会计联系方式
                    this.parames.billingStartDate = data.billingStartDate //代账起始日期
                    this.parames.billingEndDate = data.billingEndDate //代账截止日期
                    this.parames.paymentStartDate = data.paymentStartDate //缴费起始日期
                    this.parames.paymentEndDate = data.paymentEndDate //缴费截止日期
                    this.parames.arrears = data.arrears //是否欠代理费
                    this.parames.refund = data.refund //是否退代理费
                    if (data.refundWay) {
                        this.parames.refundWay = data.refundWay.name
                    }
                    this.parames.refundPerson = data.refundPerson //退费人名称
                    this.parames.refundMobile = data.refundMobile //退费人联系方式
                }
            })
        },
        resetData () {
            this.parames.contractId = '' //合同ID
            this.parames.reviewerId = '' //审批人ID
            this.parames.customerName = '' //客户名称
            this.parames.creditCode = '' //信用代码
            this.parames.fiveInOne = '' //五证合一
            this.parames.contacts = '' //企业联系人
            this.parames.contactMobile = '' //企业联系人方式
            this.parames.accountant = '' //代理会计
            this.parames.accountantMobile = '' //代理会计联系方式
            this.parames.billingStartDate = '' //代账起始日期
            this.parames.billingEndDate = '' //代账截止日期
            this.parames.paymentStartDate = '' //缴费起始日期
            this.parames.paymentEndDate = '' //缴费截止日期
            this.parames.arrears = '' //是否欠代理费
            this.parames.arrearsReason = '' //欠费原因
            this.parames.refund = '' //是否退代理费
            this.parames.refundAmount = '' //退款金额
            this.parames.refundPerson = '' //退费人名称
            this.parames.refundMobile = '' //退费人联系方式
            this.parames.refundWay = '' //退费方式
            this.parames.refundBank = '' //退费银行名称
            this.parames.refundAccount = '' //退费账号
            this.parames.businessNature = '' //企业性质（NORMAL_PERSON("一般人") SMALL_SCALE_TAXPAYER("小规模纳税人")）
            this.parames.accountingTurnover = '' //会计流转信息
            this.parames.accountInformation = '' //企业账务情况说明
            this.parames.inform = '' //告知是否企业情况
        }
    },
    computed: {
      changeDialog () {
        return this.chehuData.show
      }
    }, 
    watch: {
      changeDialog: {
        handler (curVal, oldVal) {
          if (curVal) {
                this.$utils.getEnumberation('postContactRefundWay','fukuanData',this) //退款方式
              this.parames.contractId = this.chehuData.id
              this.render()
          } else {
            this.resetData()
          }
        }
      }
    }
};
</script>

<style>
#seachDialog .el-dialog{
    padding-bottom: 0; 
    overflow-x: hidden;
}
#seachDialog .el-dialog__footer{
    border-top: #f4f4f4 solid 1px;
}
</style>
